package com.bigfreakindeals.Models;

import java.util.ArrayList;
import java.util.List;

import android.util.Log;

public class Company {
	private String companyID;
	private String companyname;
	private String companyslug;
	private String companyAddress1;
	private String companyAddress2;
	private String phoneNumber;
	private String zip;
	private String cityname;
	private String statename;
	private String webSite;
	private String longitude;
	private String latitude;
	private List<Branch> branchOffice = null;
	private String companyString;
	
	public Company() {
	}
	public String getPlainString(){
		
		String plainString="";
	if (companyname!=null && companyAddress1!=null){
			
		plainString  =  ""+companyname;
			
		plainString += ((companyAddress1!=null && companyAddress1.length()>0) ? (companyAddress1) +" ": " " );
		plainString += ((companyAddress2!=null && companyAddress2.length()>0) ? (companyAddress2) +" \n": "\n " );
			
		plainString += ((phoneNumber!=null && phoneNumber.length()>0)?""+" "+phoneNumber+"":"");
		plainString +=(" \n");

		
	}
		return plainString;
			
	}
		
	public String getString(){
		
		String retString = "";
		if (companyname!=null && companyAddress1!=null){
			retString  =  "<p>"+companyname;
			retString += ((companyAddress1!=null && companyAddress1.length()>0) ? ("<br>"+companyAddress1) : " " );
			retString += ((companyAddress2!=null && companyAddress2.length()>0) ? ("<br>"+companyAddress2) : " " );
		
			retString += ((cityname!=null && cityname.length()>0)?""+"<br>"+cityname : " ");
			System.out.println(" getString STATE"+statename);
			
			retString += ((statename!=null && statename.length()>0)?""+" "+statename :" ");
			retString += ((zip!=null && zip.length()>0)?""+", "+zip:"");
		
			retString += ((phoneNumber!=null && phoneNumber.length()>0)?""+"<br><a href=\"PHONE:"+phoneNumber+"\">"+phoneNumber+"</a><br/>":"");
			
			retString += ((webSite!=null && webSite.length()>0)?"<br><a href=\"URL:"+webSite+"\">"+webSite+"</a><br>":" ");
			
			
			retString += ((latitude!=null && longitude!=null)?"<br><a href=\"MAP:"+latitude+"|"+longitude+"\">Map It!</a>":"<br>");
			
			retString = "<style type=\"text/css\">body{color: #000000; text-decoration:none;font-size: 12px;}</style>"+retString;
			
			
			}
		return retString;
		
								
		
	
	}

	public String getCompanyID() {
		return companyID;
	}

	public void setCompanyID(String companyID) {
		this.companyID = companyID;
	}

	public String getCompanyname() {
		return companyname;
	}

	public void setCompanyname(String companyname) {
		this.companyname = companyname;
	}

	public String getCompanyslug() {
		return companyslug;
	}

	public void setCompanyslug(String companyslug) {
		this.companyslug = companyslug;
	}

	public String getCompanyAddress1() {
		return companyAddress1;
	}

	public void setCompanyAddress1(String companyAddress1) {
		this.companyAddress1 = companyAddress1;
	}

	
	public String getCompanyAddress2() {
		return companyAddress2;
	}

	public void setCompanyAddress2(String companyAddress2) {
		this.companyAddress2 = companyAddress2;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getZip() {
		return zip;
	}

	public void setZip(String zip) {
		this.zip = zip;
	}

	public String getCityname() {
		return cityname;
	}

	public void setCityname(String cityname) {
		this.cityname = cityname;
	}

	public String getStatename() {
		return statename;
	}

	public void setStatename(String statename) {
		System.out.println(" SET STATE NAME"+statename);
		this.statename = statename;
	}

	public String getWebSite() {
		return webSite;
	}

	public void setWebSite(String webSite) {
		this.webSite = webSite;
	}

	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}

	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}

	public List getBranchOffice() {
		return branchOffice;
	}

	public void addBranchOffice(Branch branch) {
		if (branchOffice==null)
			branchOffice = new ArrayList<Branch>();
		branchOffice.add(branch);
		
	}
	public int getBranchCount(){
		if (branchOffice==null)
			return 0;
		else 
		return branchOffice.size();
	}

	public boolean hasBranchOffice(){
	if (branchOffice!=null)
		return true;
	else return false;
}
	public String cityStateZip(){
		if (cityname!=null && cityname.length()>0)
			return cityname +", "+statename+" "+zip;	
		else 
			return statename+" "+zip;
		
	}
}